package com.eling.elcms.travel.model;

import com.eling.elcms.basedoc.model.EnumSerializer;
import com.eling.elcms.basedoc.model.Goods;
import com.eling.elcms.core.dao.annotation.In;
import com.eling.elcms.core.dao.hibernate.search.EnumBridge;
import com.eling.elcms.core.model.BaseModel;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.hibernate.search.annotations.*;

import javax.persistence.*;

/**
 * 查房人员房间消费信息
 * 
 * @author zhoulin
 * 
 * NieCR 2016-12-12
 *
 */
@Entity
@Table(name = "travel_roomperconsumption")
@Indexed
public class RoomPerConsumption extends BaseModel {

	private static final long serialVersionUID = 8029564805290021798L;

	@Id
	@In
	@DocumentId
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long pkRoomPerConsumption;

	/** 服务点定价物品 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "pkGoods")
	@IndexedEmbedded(depth = 1)
	private Goods goods;

	/** 单价 */
	@Column
	private Double price;

	/** 数量 */
	@Column
	private Integer num;

	/** 消费类型 */
	@Enumerated(EnumType.STRING)
	@In
	@Field
	@FieldBridge(impl = EnumBridge.class)
	private ConsumptionType consumptionType;

	/** 备注 */
	@Column(length = 255)
	private String description;

	@Version
	private Integer version;

	@JsonSerialize(using = EnumSerializer.class)
	public enum ConsumptionType {
		RoomConsumption("房内消费"), DamageConsumption("赔偿消费");
		private String display;

		ConsumptionType(String display) {
			this.display = display;
		}

		public String getDisplay() {
			return display;
		}
	}

	public Long getPkRoomPerConsumption() {
		return pkRoomPerConsumption;
	}

	public void setPkRoomPerConsumption(Long pkRoomPerConsumption) {
		this.pkRoomPerConsumption = pkRoomPerConsumption;
	}

	public Goods getGoods() {
		return goods;
	}

	public void setGoods(Goods goods) {
		this.goods = goods;
	}

	public Double getPrice() {
		return price;
	}

	public void setPrice(Double price) {
		this.price = price;
	}

	public Integer getNum() {
		return num;
	}

	public void setNum(Integer num) {
		this.num = num;
	}

	public ConsumptionType getConsumptionType() {
		return consumptionType;
	}

	public void setConsumptionType(ConsumptionType consumptionType) {
		this.consumptionType = consumptionType;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

}
